import {
	defineStore
} from 'pinia'

import {
	ref
} from 'vue'

export const useInfoStore = defineStore('info', () => {
		// 存储景点、酒店、餐厅信息对象
		const InfoData = ref({})

		// 将获取到的信息存入信息对象
		const setInfoData = (data) => {
			InfoData.value = data
		}

		// 清空信息对象
		const clearInfoData = () => {
			InfoData.value = {}
		}

		return {
			InfoData,
			setInfoData,
			clearInfoData
		}
	},
	// 持久化
	{
		persist: {
			storage: {
				getItem(key) {
					return uni.getStorageSync(key)
				},
				setItem(key, value) {
					return uni.setStorageSync(key, value)
				}
			}
		}
	})